package com.github.baichuan.application.scaffold.rest.security;

import com.github.baichuan.application.scaffold.rest.domain.application.Application;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class PasswordSecurityProvider {
    private Map<String, PasswordSecurityPolicy> passwordSecurities = new ConcurrentHashMap<>();

    public PasswordSecurityPolicy get(Application application){
        String code = application.getCode();
        if(passwordSecurities.containsKey(code))
            return passwordSecurities.get(code);

        PasswordSecurityPolicy policy = PasswordSecurityPolicy.create(application);
        passwordSecurities.put(code, policy);
        return policy;
    }
}
